<html>

<head>
<title>SQL Relay - Getting Started With IBM DB2 - Installing DB2 Version 7.2</title>
<link rel="stylesheet" href="../../css/styles.css">
</head>

<body>

<span class="heading1">Installing IBM DB2 Version 7.2</span><br>

<br><br>

<a name="pdksh"></a>
<span class="heading2">Install pdksh</span><br>

<p>DB2 7.2 requires pdksh (Public Domain Korn Shell).  If it did not come with
your distribution, you'll need to download and install it.</p>

<p>For RPM based distributions, look for pdksh at 
<a href="http://rpmfind.net">rpmfind</a> and install it using <i>rpm -i</i>.</p>

<p>For Debian Linux, on newer Debian releases, if you have configured 
<i>apt</i> as illustrated in 
<a href="http://www.debian.org/doc/manuals/apt-howto/index.en.html">the 
APT-HOWTO</a>, run <i>apt-get install pdksh</i>.  If your distribution came with
pdksh, you may be prompted to enter a CD.  If not, it will be downloaded from 
the internet.<p>

<p>For Slackware Linux, the pdksh package is available from 
<a href="ftp://ftp.slackware.com">ftp.slackware.com</a>.  You can install it 
using <i>installpkg</i>.</p>

<span class="heading2">Install libncurses.so.4</span><br>

<p>DB2 7.2 requires libncurses.so.4.  Many older distributions come with 
libncurses.so.4.  Many newer distributions come with libncurses.so.5 (or newer).
Some distributions come with both.  If your distribution does NOT have 
libncurses.so.4, create a symbolic link to the newer library as follows.</p>

<p>(These instructions assume that your system has ncurses version 5.2 and that
libncurses.so.5.2 resides in /usr/lib.  If your system has a different version 
of ncurses or if it resides somewhere else (for example, in /lib) then modify 
the instructions accordingly)</p>

<blockquote>
<b>cd /usr/lib<br>
ln -s libncurses.so.5.2 libncurses.so.4</b>
</blockquote>

<span class="heading2">Install Compatibility Packages</span><br>

<p>DB2 V7.2 for Linux requires glibc 2.1.  Distributions that come with glibc
2.1 include RedHat 6, Debian 2.2, Mandrake 7 and Slackware 7.  Newer
distributions come with newer versions of glibc.  On these distributions it is
necessary to install some compatibility packages.</p>

<p>RedHat provides compatability RPM's for RedHat 7 that can actually be used
on any Linux distribution.  These RPM's can be downloaded from
<a href="http://rpmfind.net">rpmfind</a>.  You'll need the following RPM's.
</p>

<ul>
<li><b>compat-glibc-6.2-2.1.3.2.i386.rpm</b> for RedHat Linux 7.3</li>
<li><b>compat-egcs-6.2-1.1.2.16.i386.rpm</b> for RedHat Linux 7.3</li>
<li><b>compat-libstdc++-6.2-2.9.0.16.i386.rpm</b> for RedHat Linux 7.3</li>
</ul>

<p>You can install the compatibility RPM's using <i>rpm -i</i>.</p>

<span class="heading2">DB2 Installation</span><br>

<p>IBM DB2 V7.2 is available from 
<a href="http://www-3.ibm.com/software/data/db2/linux/">the IBM website</a> as
a tarball.  Extracting the tarball using <i>tar xf</i> creates a directory
called 018_EEE_LNX_NLV.  Change directories into that directory.</p>

<p>On Debian Linux and Slackware Linux, edit the db2_install script and
comment out the line:</p>

<blockquote>
<b>rpm -qa | grep rpm 1>/dev/null 2>/dev/null</b>
</blockquote>

<p>If you're installing on a computer that gets moved around a lot (such as a
laptop) and gets assigned more than 1 hostname, you should set the hostname
to localhost now using the following command:</p>

<blockquote>
<b>hostname localhost</b>
</blockquote>

<p>The installer will name the database after whatever hostname your computer
currently has.  This will cause the database to be inaccessible when that
hostname doesn't resolve or resolves to a computer other than yours.</p>

<p>Run the db2_install script.</p>

<p>When prompted to specify a keyword, type DB2.EENT and press return.</p>

<p>When the script completes, run <i>rpm -qa</i> and verify that the following 
RPM's were installed:</p>

<blockquote><b>
db2cnvc71-7.1.0-40<br>
db2gs71-7.1.0-40<br>
db2cucs71-7.1.0-40<br>
db2engn71-7.1.0-40<br>
db2cdrd71-7.1.0-40<br>
db2dj71-7.1.0-40<br>
db2pext71-7.1.0-40<br>
db2cliv71-7.1.0-40<br>
db2rte71-7.1.0-40<br>
db2wcc71-7.1.0-40<br>
db2hten71-7.1.0-40<br>
db2cnvk71-7.1.0-40<br>
db2cj71-7.1.0-40<br>
db2conn71-7.1.0-40<br>
db2smpl71-7.1.0-40<br>
db2xlic71-7.1.0-40<br>
db2cnvj71-7.1.0-40<br>
db2crte71-7.1.0-40<br>
db2cdb71-7.1.0-40<br>
db2das71-7.1.0-40<br>
db2cnvt71-7.1.0-40<br>
db2repl71-7.1.0-40<br>
db2adts71-7.1.0-40<br>
db2jdbc71-7.1.0-40<br>
db2adt71-7.1.0-40<br>
</b></blockquote>

<span class="heading2">Ignore the Misinformation</span><br>

<p>There are many, many instances where the DB2 Version 7.2 distribution
identifies itself as version 7.1 instead of 7.2.  For example, the RPM's have a
7.1.0 version number.  These clues might lead one to think that he or she has
accidentally installed version 7.1 instead of version 7.2, but this is not the
case.</p>

<span class="heading2">Install the Documentation</span><br>

<p>For version 7.2, once the RPM's are installed, you can install the
documentation by running <i>/usr/IBMdb2/V7.1/doc/db2insthtml en_US</i>.
To view the documentation, point your browser at
<a href="file://usr/IBMdb2/V7.1/doc/en_US/html">
/usr/IBMdb2/V7.1/doc/en_US/html</a>.</p>

<a name="odbc"></a>
<span class="heading2">Restore unixODBC if Necessary</span><br>

<p>The DB2 installation creates symbolic links from include files in 
its base directory to /usr/include.  If you had a unixODBC-devel RPM 
installed prior to installing DB2, the include files provided by the 
unixODBC-devel RPM will have been overwritten by these symbolic links.  You 
should probably reinstall the unixODBC-devel RPM.  SQL Relay looks in 
the DB2 installation directory for DB2 includes, so not having them in
/usr/include won't hurt, but not having the proper unixODBC includes in
/usr/include will cause the ODBC database connection build to fail.</p>

<p>This should be enough you get you started.  To set up more complex 
configurations, consult the documentation that came with your DB2
distribution.</p>

<span class="heading2">Creating an Instance</span><br>

<p>IBM DB2 is installed under either /opt/IBMdb2/V7.1, /usr/IBMdb2/V7.1 
That directory will be referred to as <i>BASE_DIR</i> in this document.</p>

<p>A DB2 installation consists of an administration server and one or more
instances.  Each instance contains one or more databases.  The administration 
server coordinates the instances.  The administration server is owned by an 
OS-level user.  Each instance is owned by a seperate OS-level user as well.</p>

<p>To create an instance and an administration server, run 
<i>BASE_DIR/install/db2setup</i>, a text-based installation program.</p>

<blockquote>
Select <b>[ Create... ]</b><br>
Select <b>Create a DB2 Instance</b><br>
Accept the default user name (db2inst1).<br>
Accept the default UID.<br>
Accept the default group name (db2iadm1).<br>
Accept the default GID.<br>
Pick a password.<br>
Select <b>[ OK ]</b><br>
<br>
A screen for creating the Fenced User (the user that will run user defined
functions and stored procedures) will now appear.<br>
<br>
Accept the default user name (db2fenc1).<br>
Accept the default UID.<br>
Accept the default group name (db2fadm1).<br>
Accept the default GID.<br>
Pick a password.<br>
Select <b>[ OK ]</b> This will return you to <b>Create DB2 Services</b>
screen.<br>
<br>
Select <b>Create the Administration Server</b><br>
Accept the default user name (db2as).<br>
Accept the default UID.<br>
Accept the default group name (db2asgrp).<br>
Accept the default GID.<br>
Pick a password.<br>
Select <b>[ OK ]</b><br>
If you get a <b>DB2SYSTEM will be set to ...</b> dialog, select 
<b>[ OK ]</b>.<br>
<br>
On the <b>Create DB2 Services</b> screen, select <b>[ OK ]</b><br>
Select <b>[ Continue ]</b><br>
Select <b>[ OK ]</b> in the <b>This is your last chance to stop</b> 
dialog.<br>
<br>
Now the instance and administration server will be created.<br>
If all went well, you'll get a <b>Completed Sucessfully.</b> notice.<br>
To exit,<br>
Select <b>[ OK ]</b><br>
Select <b>[ OK ]</b><br>
Select <b>[ Close ]</b><br>
Select <b>[ OK ]</b>
</blockquote>

<p>Should you need to create additional DB2 instances, follow this procedure 
again using a different user name and skipping the steps pertaining
to the Administration Server.  The <i>BASE_DIR/instance/db2ilist</i> 
command lists all of the DB2 instances on the local computer.</p>

<p>If you need to drop an instance, run 
<i>BASE_DIR/instance/db2idrop instancename</i>, substituting the name of
the instance you want to drop for instancename.</p>

<p>The <i>BASE_DIR/instance/dasilist</i> command lists all of the DB2 
administration servers on the local computer.</p>

<p>If you need to drop an administration server, run 
<i>BASE_DIR/instance/dasidrop servername</i>, substituting the name of
the administration server you want to drop for servername.</p>

<span class="heading2">Enable Remote Access</span><br>

<p>By default, a DB2 instance only accept connections from clients running on 
the local machine.  To enable connections from clients running on a remote 
machine over TCP, execute commands like the following.  These commands set 
up the <i>db2inst1</i> instance on port 50000.</p>

<blockquote>
log in as root<br>
view <i>/etc/services</i> and look for a line like:<br>
<blockquote><b>
db2cdb2inst1     50000/tcp  # Connection port for DB2 instance db2inst1<br>
</b></blockquote>
if no such line exists, add it
<br>
log in as db2as<br>
run the following commands:<br>
<blockquote><b>
. /home/db2inst1/sqllib/db2profile<br>
db2 "update database manager configuration using svcename db2inst1"<br>
db2stop<br>
db2start<br>
</b></blockquote>
</blockquote>

<p>Now the <i>db2inst1</i> instance should be accessible to remote clients on 
port 50000.</p>

<span class="heading2">Starting the Database at Boot Time</span><br>

<p>During the DB2 installation process, /etc/inittab is modified such that
the database will be started at boot time.  However, if you would like to start
and stop the database at will, you can use the following script.</p>

<blockquote>
<PRE>
<FONT color=#0000ff>#!/bin/sh</FONT>

<B><FONT color=#a62828>case</FONT></B> &quot;$1&quot; <B><FONT color=#a62828>in</FONT></B>
        start<B><FONT color=#a62828>)</FONT></B>
                /usr/IBMdb2/V7.1/instance/db2istrt
        <B><FONT color=#a62828>;;</FONT></B>
        stop<B><FONT color=#a62828>)</FONT></B>
                /usr/IBMdb2/V7.1/instance/db2ishut
        <B><FONT color=#a62828>;;</FONT></B>
        *<B><FONT color=#a62828>)</FONT></B>
        <B><FONT color=#a62828>echo</FONT></B><FONT color=#ff00ff> $</FONT><B><FONT color=#a62828>&quot;</FONT></B><FONT color=#ff00ff>Usage: </FONT><FONT color=#a620f7>$0</FONT><FONT color=#ff00ff> {start|stop}</FONT><B><FONT color=#a62828>&quot;</FONT></B>
        <B><FONT color=#a62828>exit</FONT></B> <FONT color=#ff00ff>1</FONT>
<B><FONT color=#a62828>esac</FONT></B>

<B><FONT color=#a62828>exit</FONT></B> <FONT color=#ff00ff>0</FONT>


</PRE>
</blockquote>

<p>Install this script and run it with the "start" option to start up the
database.  Running it with the "stop" option shuts the database down.  To
access a database, it must be running.</p>

<p>You can control which instances start at boot time using the following
commands.  To get each instance to start at boot time, you need to run the
following command as root for each instance:</p>

<blockquote>
<b>/usr/IBMdb2/V7.1/bin/db2iauto -on INSTANCE_USER</b>
</blockquote>

<p>Where INSTANCE_USER is replaced by the username of the user associated with
the instance you want to start at boot time.</p>

<p>If you want to disable an instance from starting at boot time, you need to
run the following command as root for each instance:</p>

<blockquote>
<b>/usr/IBMdb2/V7.1/bin/db2iauto -off INSTANCE_USER</b>
</blockquote>

</body>

</html>
